<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "{{%admin_log}}".
 *
 * @property integer $id
 * @property string $route
 * @property string $description
 * @property integer $user_id
 * @property string $ip
 * @property integer $create_at
 */
class AdminLog extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%admin_log}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['description', 'user_id', 'create_at'], 'required'],
            [['description'], 'string'],
            [['user_id', 'create_at'], 'integer'],
            [['route'], 'string', 'max' => 255],
            [['ip'], 'string', 'max' => 32],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'route' => '路由',
            'description' => '描述',
            'user_id' => '管理员ID',
            'ip' => '登陆IP',
            'create_at' => '添加时间',
        ];
    }

    protected function getUser()
    {
        return $this->hasOne(User::className(),['id'=>'user_id']);
    }
}
